package com.ztn.iot.zhonghaichi2.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.ztn.base.util.common.TimeTool;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @author zhm
 */

@Component
public class MyBatisMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        int time = TimeTool.time();
        this.setFieldValByName("createdDate", time, metaObject);
        this.setFieldValByName("updateDate", time, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        int time = TimeTool.time();
        this.setFieldValByName("updateDate", time, metaObject);
    }
}
